home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / 80X86 / AMISL092.ZIP / FASTMOUS.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-09-24  |  4.0 KB  |  151 lines

  1. ;-----------------------------------------------------------------------
  2. ; FASTMOUS.ASM    Public Domain 1992, 1993, 1995 Ralf Brown
  3. ;        You may do with this software whatever you want, but
  4. ;        common courtesy dictates that you not remove my name
  5. ;        from it.
  6. ;
  7. ; Convert slow (on some systems) hardware reset mouse call into a fast
  8. ; software reset call.    This is a demonstration program to show just
  9. ; how small a useful program can be made and still be fully compliant
  10. ; with the alternate multiplex interrupt specification v3.4.  FASTMOUS
  11. ; contains just 128 bytes of resident code and data.
  12. ;
  13. ; Version 0.92
  14. ; LastEdit: 9/24/95
  15. ;-----------------------------------------------------------------------
  16.  
  17.     INCLUDE AMIS.MAC
  18.  
  19.     @Startup 2,00            ; need DOS 2.00
  20.                     ; this macro also takes care of declaring
  21.                     ; all the segments in the required order
  22.  
  23. ;-----------------------------------------------------------------------
  24. ;
  25. VERSION_NUM equ 005Ch    ; v0.92
  26. VERSION_STR equ "0.92"
  27.  
  28. ;-----------------------------------------------------------------------
  29. ;
  30. ; useful macros
  31. ;
  32. LODSB_ES MACRO
  33.     DB 26h,0ACh    ; LODSB ES:
  34.     ENDM
  35.  
  36. ;-----------------------------------------------------------------------
  37. ; Put the resident code into its own segment so that all the offsets are
  38. ; proper for the new location after copying it into a UMB or down into
  39. ; the PSP.
  40. ;
  41. TSRcode@
  42.  
  43. ;-----------------------------------------------------------------------
  44. ; Declare the interrupt vectors hooked by the program, then set up the
  45. ; Alternate Multiplex Interrupt Spec handler
  46. ;
  47.     HOOKED_INTS 2Dh,33h        ; it isn't actually necessary to list 2Dh
  48.     ALTMPX    'Ralf B','FASTMOUS',VERSION_NUM
  49.  
  50. ;-----------------------------------------------------------------------
  51. ; Now the meat of the resident portion, the mouse interrupt handler.
  52. ; We can save one byte by specifying the hardware reset handler set up by
  53. ; the ALTMPX macro above
  54. ;
  55.     ISP_HEADER 33h,hw_reset_2Dh
  56.     or    ax,ax            ; hardware reset call?
  57.     jne    use_old_int33        ; skip if not
  58.     push    ds
  59.     mov    ds,ax                 ; DS <- 0000h
  60.     test    byte ptr ds:[417h],13h    ; shift or scroll lock pressed?
  61.     pop    ds
  62.     jnz    use_old_int33        ; skip if yes
  63.     mov    al,21h            ; do software reset instead
  64. use_old_int33:
  65.     jmp    ORIG_INT33h
  66.  
  67. TSRcodeEnd@
  68.  
  69. ;-----------------------------------------------------------------------
  70.  
  71. _TEXT SEGMENT 'CODE'
  72.     ASSUME cs:_TEXT,ds:_INIT,es:TGROUP,ss:NOTHING
  73.  
  74. banner     db 'FASTMOUS v',VERSION_STR,'  Public Domain 1993 Ralf Brown  '
  75.     db '[Type "FASTMOUS R" to remove]',13,10,"$"
  76. installed_msg     db "Installed.",13,10,"$"
  77. already_inst_msg db "Already installed.",13,10,"$"
  78. no_driver_msg     db "No mouse driver -- can't install.",13,10,"$"
  79. cant_remove_msg  db "Can't remove from memory.",13,10,"$"
  80. uninstalled_msg  db "Removed.",13,10,"$"
  81.  
  82.  
  83.     @Startup2    Y
  84.     push    ds
  85.     pop    es
  86.     ASSUME    ES:_INIT
  87.     push    cs
  88.     pop    ds
  89.     ASSUME    DS:_TEXT
  90.     ;
  91.     ; say hello
  92.     ;
  93.     DISPLAY_STRING banner
  94.     mov    bx,1000h        ; set memory block to 64K
  95.     mov    ah,4Ah
  96.     int    21h
  97.     mov    si,81h            ; SI -> command line
  98.     cld                ; ensure proper direction for string ops
  99. cmdline_loop:
  100.     lodsb_es
  101.     cmp    al,' '            ; skip blanks and tabs on commandline
  102.     je    cmdline_loop
  103.     cmp    al,9
  104.     je    cmdline_loop
  105.     and    al,0DFh            ; force to uppercase
  106.     cmp    al,'R'
  107.     je    removing
  108. installing:
  109.     ;
  110.     ; place any necessary pre-initialization here
  111.     ;
  112.     mov    ax,3533h
  113.     int    21h
  114.     mov    ax,es
  115.     or    ax,bx            ; is INT 33h hooked already?
  116.     mov    dx,offset _TEXT:no_driver_msg
  117.     jz    exit_with_error        ; if not hooked, we can't install
  118.     ;
  119.     ; OK, now ready to install
  120.     ;
  121.     INSTALL_TSR ,BEST,TOPMEM,inst_notify,already_installed
  122.  
  123. removing:
  124.     UNINSTALL cant_uninstall
  125.     push    cs
  126.     pop    ds
  127.     ASSUME    DS:_TEXT
  128.     DISPLAY_STRING uninstalled_msg
  129.         mov     ax,4C00h
  130.     int    21h
  131.  
  132. cant_uninstall:
  133.     mov    dx,offset _TEXT:cant_remove_msg
  134.     jmp short exit_with_error
  135. already_installed:
  136.     mov    dx,offset _TEXT:already_inst_msg
  137. exit_with_error:
  138.     mov    ah,9
  139.     int    21h
  140.     mov    ax,4C01h
  141.     int    21h
  142.  
  143. inst_notify:
  144.     DISPLAY_STRING installed_msg
  145.     ret
  146.  
  147. _TEXT ENDS
  148.  
  149.      end INIT
  150.  
  151.